import request from '@/utils/request';

/**
 * 获取入职配置简要列表
 */
export const getEntryConfig = () =>
    request('/api/entry/v1/configs', {
        method: 'POST'
    });

// 获取入职默认配置
export const getDefaultConfigByType = settingType =>
    request(`/api/entry/v1/configs/${settingType}/default`, {
        method: 'POST'
    });

/**
 * 获取所有入职流程配置
 */
export const getEntryFlowConfig = id => {
    if (id) {
        return request(`/api/entry/config/v1/employee/getEntryFlowConfigDetail/${id}`, {
            method: 'POST'
        });
    }
    return request('/api/entry/config/v1/employee/getEntryFlowsConfig', {
        method: 'POST'
    });
};

// 获取初始化入职流程配置
export const getEntryFlowDefaultConfig = () =>
    request('/api/entry/config/v1/employee/initSaveEntryFlowConfig', {
        method: 'POST'
    });

// 编辑入职流程配置
export const saveEntryFlowConfig = params =>
    request('/api/entry/config/v1/employee/modEntryFlowConfig', {
        method: 'POST',
        data: params
    });

// 通过机构列表查询岗位, 返回数据中的岗位如果不在改行政机构下, 会被禁用
export const getDutyListByOrganizationV2 = ({ organizationCode, showTreeFlag }) =>
    request('/api/org/v1/duty/queryDutyListByOrganizationV2', {
        method: 'POST',
        data: { organizationCode, showTreeFlag }
    });

/**
 * 删除入职流程配置
 * @param id
 * @returns {Promise<any|{}|{data: *&{data: *}}|{data: *}>}
 */
export const deleteEntryFlowConfig = id =>
    request(`/api/entry/config/v1/employee/removeEntryFlowConfig/${id}`, {
        method: 'DELETE'
    });

export const deleteEntryMaterialById = id =>
    request(`/api/entry/config/v1/materials/${id}`, {
        method: 'DELETE'
    });

export const getEntryRemindMailData = () =>
    request('/todo', {
        method: 'GET'
    });

export const getEntryAssetsData = () =>
    request('/todo', {
        method: 'GET'
    });

/**
 * 获取入职须知模板详情
 * @param id
 * @returns {Promise<any|{}|{data: *&{data: *}}|{data: *}>}
 */
export const getGuideNoticeConfig = id =>
    request(`/api/entry/config/v1/notes/${id}`, {
        method: 'POST'
    });

/**
 * 入职须知模板添加和修改
 * @param params
 * @returns {Promise<any|{}|{data: *&{data: *}}|{data: *}>}
 */
export const saveGuideNoticeConfig = params =>
    request('/api/entry/config/v1/notes', {
        method: 'POST',
        data: params
    });

/**
 * 删除入职须知模板
 * @param id
 * @returns {Promise<any|{}|{data: *&{data: *}}|{data: *}>}
 */
export const deleteGuideNoticeConfig = id =>
    request(`/api/entry/config/v1/notes/${id}`, {
        method: 'DELETE'
    });

/**
 * 获取入职欢迎信模板详情
 * @param id
 * @returns {Promise<any|{}|{data: *&{data: *}}|{data: *}>}
 */
export const getEntryWelcomeConfig = id =>
    request(`/api/entry/config/v1/entryWelcome/${id}`, {
        method: 'GET'
    });

// 获取入职欢迎信默认数据
export const getEntryWelcomeDefaultConfig = () =>
    request('/api/entry/config/v1/entryWelcome', {
        method: 'POST'
    });

/**
 * 入职欢迎信模板添加和修改
 * @param params
 * @returns {Promise<any|{}|{data: *&{data: *}}|{data: *}>}
 */
export const saveEntryWelcomeConfig = params =>
    request('/api/entry/config/v1/entryWelcome/saveData', {
        method: 'POST',
        data: params
    });

/**
 * 删除欢迎信
 * @param id
 * @returns {Promise<any|{}|{data: *&{data: *}}|{data: *}>}
 */
export const deleteEntryWelcomeConfig = id =>
    request(`/api/entry/config/v1/entryWelcome/${id}`, {
        method: 'DELETE'
    });

/*
 * 通过机构列表查询岗位
 * @returns {Promise<any|{}|{data: *&{data: *}}|{data: *}>}
 */
export const getDutyListByOrganization = params =>
    request('/api/org/v1/duty/queryDutyListByOrganization', {
        method: 'POST',
        data: params
    });

/**
 *
 * 通过ID获取入职材料详情
 * */
export const fetchEntryMaterialById = id =>
    request(`/api/entry/config/v1/materials/${id}`, {
        method: 'POST'
    });

/**
 * 获取组织机构列表
 */
export const fetchOrgList = () =>
    request('/api/uc/org/ads/v1/orgLinkList', {
        method: 'POST'
    });

/**
 * 通过ID获取材料详情（编辑）
 */
export const fetchEditEntryMaterialsById = params =>
    request('/api/entry/config/v1/materials', {
        method: 'POST',
        data: params
    });

/**
 * 获取字典
 */
export const fetchEntrySettingTemplateDictionary = params =>
    request('/api/dict/v1/getList', {
        method: 'POST',
        data: params
    });

/**
 * 编辑劳动合同模板
 * @param params
 */
export const saveContractTemplate = params =>
    request('/api/entry/config/v1/employee/modContractTemplate', {
        method: 'POST',
        data: params
    });
/**
 * 获取入职劳动合同配置详情
 * @param params
 */
export const getEntryContractTemplateConfigDetail = id =>
    request(`/api/entry/config/v1/employee/getEntryContractTemplateConfigDetail/${id}`, {
        method: 'POST'
    });

/**
 * 入职提醒日期修改
 * @param params
 */
export const editEntryMailDay = params =>
    request('/api/entry/config/v1/entryMail/day', {
        method: 'POST',
        data: params
    });

export const deleteEntryContractTemplateConfig = id =>
    request(`/api/entry/config/v1/employee/removeEntryContractTemplateConfig/${id}`, {
        method: 'DELETE'
    });

export const editEntryMaterial = params =>
    request('/api/entry/config/v1/materials', {
        method: 'POST',
        data: params
    });

/**
 * 获取入职时间变更邮件模板配置详情
 * @param params
 */
export const getEntryTimeChangeMailTemplateDetail = id =>
    request(`/api/entry/config/v1/employee/getEntryTimeChangeMailTemplateDetail/${id}`, {
        method: 'POST'
    });

/**
 * 编辑入职时间变更邮件模板
 * @param params
 */
export const saveEntryTimeChangeMailTemplate = params =>
    request('/api/entry/config/v1/employee/modEntryTimeChangeMailTemplate', {
        method: 'POST',
        data: params
    });
/**
 * 删除入职时间变更邮件模板
 * @param id
 */
export const removeEntryTimeChangeMailTemplate = id =>
    request(`/api/entry/config/v1/employee/removeEntryTimeChangeMailTemplate/${id}`, {
        method: 'DELETE'
    });
/**
 * 删除入职提醒邮件模板
 * @param id
 */
export const removeEntryRemindMailTemplate = id =>
    request(`/api/entry/config/v1/entryMail/${id}`, {
        method: 'DELETE'
    });
/**
 * 入职提醒邮件模板添加和修改
 */
export const saveEntryRemindMailTemplate = params =>
    request('/api/entry/config/v1/entryMail', {
        method: 'POST',
        data: params
    });
/**
 * 入职提醒邮件模板详情获取
 * @param id
 */

export const getEntryRemindMailDetail = id =>
    request(`/api/entry/config/v1/entryMail/${id}`, {
        method: 'POST'
    });
// 获取入职资产初始化配置
export const getEntryAssetsConfig = () =>
    request('/api/entry/config/v1/employee/initEntryAssetsConfig', {
        method: 'POST'
    });

// 提交入职资产配置
export const postEntryAssetsConfig = params =>
    request('/api/entry/config//v1/employee/editEntryAssetsConfig', {
        method: 'POST',
        data: params
    });
// 获取入职资产详情
export const getEntryAssetsConfigDetail = id =>
    request(`/api/entry/config/v1/employee/queryEntryAssetsConfig/${id}`, {
        method: 'POST'
    });

// 删除入职资产配置
export const deleteEntryAssetsConfig = id =>
    request(`/api/entry/config/v1/employee/removeEntryAssetsConfig/${id}`, {
        method: 'DELETE'
    });
